home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-04 | 55.8 KB | 1,805 lines |
- Newsgroups: comp.sources.misc
- From: alan@tharr.UUCP (Alan Saunders)
- Subject: v25i021: QBATCH - a queued batch processing system for UNIX, Part02/06
- Message-ID: <1991Nov5.034628.4930@sparky.imd.sterling.com>
- X-Md4-Signature: 0646577a1904b6ae9e177e210480e597
- Date: Tue, 5 Nov 1991 03:46:28 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: alan@tharr.UUCP (Alan Saunders)
- Posting-number: Volume 25, Issue 21
- Archive-name: QBATCH/part02
- Environment: UNIX
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 6)."
- # Contents: NOTICE doc/chap.01 doc/chap.03 doc/glossary man/js.l
- # man/qf.l man/qt.l man/queue.l src/jm.c src/jn.c src/qbatch.h
- # src/qs.c src/qt.c src/time.c
- # Wrapped by root@vfib_d on Thu Oct 31 15:46:39 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'NOTICE' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'NOTICE'\"
- else
- echo shar: Extracting \"'NOTICE'\" \(3179 characters\)
- sed "s/^X//" >'NOTICE' <<'END_OF_FILE'
- X QBATCH .. a queued batch processing system for UNIX
- X
- Disclaimer
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- QBATCH is distributed free of charge in the hope that you may be able to
- make some use of it. It is however distributed AS IS, WITHOUT ANY WARRANTY, not
- even that of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It's up to
- you to decide if it fits your purpose.
- X
- XExcept where required by applicable law, or previously agreed in writing,
- neither the author, nor the copyright holders will accept any responsibility for
- what you may or may not do with these programs on your systems. No liability for
- damage, real or imagined, direct or consequential, to you, your brain, your
- system or your data, (or for that matter anything else), caused by or thought to
- be caused by or in any way related to QBATCH and/or it's related programs, will
- be accepted or even entertained. If you deem these programs suitable for
- installing and using on your system, you take full responsibility for them.
- X
- Whilst the QBATCH system is copyright material, it is freely distributable, and
- permission is hereby given to all and sundry to make what they will of it,
- provided that they adhere to the following:
- X
- X1. The sources, scripts, documentation, and in particular ANY COPYRIGHT,
- X LICENSE, AND DISCLAIMER NOTICES, shall remain intact and distributed
- X together as a coherent unit. NO PART of the QBATCH suite shall be
- X distributed separately without the express permission of the author or
- X the copyright holders.
- X
- X2. The QBATCH suite of programs shall NOT be distributed for profit.
- X Distributors of freely available software may make reasonable charges
- X for handling and media, but no part of it may be ascribed to the
- X functionality or usefulness of QBATCH. Computer systems making software
- X available to either the public, or private subscribers, internet
- X archive sites and the like, are given permission to carry QBATCH, and
- X make it available to their subscribers, provided no additional charges
- X are made to their subscribers for doing so.
- X Commercial software distributors, and software houses who may want to
- X distribute QBATCH separately, as part of, or bundled with other
- X commercial offerings should contact the author for written permission.
- X
- X3. (This is more a request than a condition) If any bugs are found and
- X fixed, or any enhancements are made, or any changes made in order to
- X port QBATCH to a different environment, Please forward the details,
- X either as modified sources, include files, or context diffs to me so
- X that they can be incorporated in future releases.
- X
- X
- In short.. I wrote QBATCH, No one else has the right to put their name to it.
- X No one else has the right to make money from my work (without me getting
- X my cut!).
- X If one or more of you gurus and 'nix wizards out there make a
- X significant contribution to QBATCH, please get the changes to me so
- X they can be incorporated in the general distribution, you will be
- X duly acknowledged in the documentation.
- X
- Alan Saunders July 1991.
- END_OF_FILE
- if test 3179 -ne `wc -c <'NOTICE'`; then
- echo shar: \"'NOTICE'\" unpacked with wrong size!
- fi
- # end of 'NOTICE'
- fi
- if test -f 'doc/chap.01' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/chap.01'\"
- else
- echo shar: Extracting \"'doc/chap.01'\" \(4290 characters\)
- sed "s/^X//" >'doc/chap.01' <<'END_OF_FILE'
- X QBATCH .. a queued batch processing system for UNIX
- X
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X1. INTRODUCTION
- X
- X What is a queued batch processing system?
- X Coming from a system where queued batch processing is part of the operating
- X system to *NIX, I wondered how users, and administrators ever got on
- X without one. At it's simplest it is a means of submitting tasks to the
- X system so that they are processed one at a time in the background. Running
- X tasks in the background is not foreign to *NIX users, they have at, batch,
- X and of course '&'. They have themselves however to keep track of the job's
- X output (both stdout and stderr), and there is no formal control (except for
- X permissions and access rights) over what is done, and in what order.
- X A queued batch processing system is precisely that. Tasks, or jobs
- X submitted to it are placed in a queue, and are processed singly from that
- X queue.
- X
- X There are several major advantages to this approach.
- X
- X A. From a user's point of view, the order of processing is defined (by the
- X order in which the jobs were submitted). This means that co-operative jobs
- X (jobs which rely on the output of prior jobs, and jobs which use common
- X resources) can be relied upon to act correctly.
- X
- X B. Again from the user's point of view, instead of having to wait until all
- X 'background' work has finished before being able to log off, (assuming he
- X or she used '&') several jobs can be submitted and left to run. The results
- X can be checked the next time he or she logs on.
- X
- X C. From an administrator's point of view, the first benefit is less loading
- X of system resources. Several jobs running consecutively in a queue use
- X less resources than if they were run concurrently.
- X
- X QBATCH is an implementation of queued batch processing which provides
- X additional functionality.
- X
- X A. There can be multiple queues. Depending on available system resources,
- X rather than a single queue for all jobs, separate queues can be assigned
- X for perhaps different user groups, or different job types. This reduces
- X the average time a job is queued waiting to be processed, and improves user
- X satisfaction.
- X
- X B. Queues can be prioritised. The nice value of a process determines the
- X scheduling priority assigned by the kernel. Whilst users can 'renice'
- X their processes if they are resource hogs, how often do they actually do
- X so? QBATCH queues can be assigned a nice value, to which all jobs
- X processed in this queue are 'reniced' automatically when run.
- X
- X C. QBATCH copes with job output gracefully. There is no longer any need
- X for users to remember to redirect stdout and stderr when running batch
- X jobs, this is done automatically by QBATCH. Both stdout and stderr are
- X combined into a 'monitor' for the job, which for any given queue and user
- X will always be written to the same place.
- X
- X D. QBATCH queues can be started and stopped (by the super user) at ANY
- X time, even from within a QBATCH job, or from cron. This allows the
- X administrator to better schedule system resources by reducing the batch
- X load during periods of high interactive activity, whilst still allowing
- X users to queue jobs for later processing.
- X
- X E. Access to QBATCH queues is entirely under the control of the super user.
- X Queues can be disabled (preventing anybody from submitting jobs) and
- X enabled at any time. Fixed context queues can limit access to a stated
- X list of uids or gids.
- X
- X F. Control of jobs in a queue is governed by job ownership. The job is
- X normally (except in some cases of fixed context queues) owned by the user
- X submitting it. The super user naturally has effective ownership of all
- X jobs. The owner of a job can remove it from the queue, or kill it if it is
- X actually running. He or she can change the order of their own jobs in the
- X queue. (This is limited to any consecutive group of that owners jobs, a
- X user is not permitted to move a job to a position in a queue earlier than a
- X job owned by another user.)
- END_OF_FILE
- if test 4290 -ne `wc -c <'doc/chap.01'`; then
- echo shar: \"'doc/chap.01'\" unpacked with wrong size!
- fi
- # end of 'doc/chap.01'
- fi
- if test -f 'doc/chap.03' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/chap.03'\"
- else
- echo shar: Extracting \"'doc/chap.03'\" \(3956 characters\)
- sed "s/^X//" >'doc/chap.03' <<'END_OF_FILE'
- X QBATCH .. a queued batch processing system for UNIX
- X
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X3. ADMINISTRATION commands.
- X
- X Note: this is a descriptive text. Full details of all the QBATCH commands
- X are provided in the relevant man pages. There is also a man page for QBATCH
- X which contains a summary of all QBATCH commands.
- X See also USER commands.
- X
- X Administration commands are those accessible only to the super user
- X (administrator).
- X
- X qc Queue create. The administrator may create as many or as few queues as
- X his system performance and his users will tolerate. At it's simplest:
- X qc name
- X qc will create a file in QBATCH queue format in QUEUEPATH (defined
- X during implementation) with the specified name and the following
- X parameters:
- X
- X Open. The queue will not be fixed context, and any user can submit
- X jobs.
- X
- X Enabled. The enabled flag will be set allowing users to submit jobs
- X immediately.
- X
- X Stopped. There will be no process engine running.
- X
- X Spooling. The default SPOOLPATH (defined during implementation) will
- X be used in which to create job files.
- X
- X Monitor. The default monitor of SPOOLPATH/name.mon will be used.
- X
- X Priority.The default priority or nice value of 0 (zero) will be used.
- X
- X All of these values (except QUEUEPATH which must be fixed) may be
- X varied by options to the qc program.
- X If a queue already exists with the same name, then qc will apply any
- X options as changes to the queue.
- X
- X qp Queue process. This program starts a queue process engine for the named
- X queue. An active process engine for a given queue holds an exclusive
- X lock on a file in QUEUEPATH, so preventing multiple iterations of qp on
- X the same queue.
- X
- X qs Queue stop. This program sets the stop flag for the named queue, and
- X sends a signal to the appropriate process engine. On receipt of the
- X signal, qp examines the kill flag, and if set, kills the running job.
- X In any case, when the job terminates, or is killed, qp itself will
- X terminate. Any jobs left in the queue will remain (unless removed
- X with jk) until the next time qp is run on this queue. The kill flag
- X may be set by qs with either of the following options:
- X
- X -k Set the kill flag.. cause qp to terminate immediately.
- X
- X -r Set the repeat and kill flags.. cause qp to terminate
- X immediately but leaving the current job in the queue for
- X reprocessing.
- X
- X If neither option is used, and the kill flag is not set, the process
- X engine will wait for the current job to complete before terminating.
- X
- X Normally qs will terminate immediately it has sent a signal to the
- X process engine. qs may be forced to wait until the current job has
- X finished and the process engine has terminated by using the -w option.
- X
- X qd Queue disable. Unset the enabled flag for a queue. This causes js to
- X reject job submissions to this queue.
- X
- X qe Queue enable. Set the enabled flag for a queue. Allow users to submit
- X jobs to the queue. (this is the default state).
- X
- X qh Queue halt. Sets the halt flag for a named queue and sends a signal to
- X the appropriate process engine. On receipt of the signal, qp checks
- X the queue flags, and finding that the halt flag has been set, sends a
- X SIGHALT to the job. This has the effect of halting it in it's tracks.
- X The kernel will swap the job out, and will not reschedule it until the
- X job receives a SIGCONT. This can be used to hold up a particularly
- X heavy job until a more appropriate time without actually killing it.
- X
- X qg Queue go. Unsets the halt flag for a named queue (if it is set), and
- X sends a signal to the process engine. qp, on receipt of the signal,
- X will send a SIGCONT to the job to resume it's processing after a
- X halt.
- X
- X qw (cf qs -w) queue wait. Wait for a process engine to terminate for a
- X given queue.
- END_OF_FILE
- if test 3956 -ne `wc -c <'doc/chap.03'`; then
- echo shar: \"'doc/chap.03'\" unpacked with wrong size!
- fi
- # end of 'doc/chap.03'
- fi
- if test -f 'doc/glossary' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/glossary'\"
- else
- echo shar: Extracting \"'doc/glossary'\" \(3787 characters\)
- sed "s/^X//" >'doc/glossary' <<'END_OF_FILE'
- X
- X QBATCH a queued batch processing system for UNIX
- X
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- GLOSSARY
- X
- BINDIR The directory path specified in the Makefile, where
- X the compiled program binaries will be installed.
- X
- entryno The identifier created by js (qv) which relates
- X to the position of a job in a queue.
- X
- fixed context A queue whose fixed context flag is set and for which
- X a .<queuename>rc file exists in QUEUEPATH to direct
- X the submission and processing of jobs.
- X
- jcl Commands in the syntax of the processing shell.
- X (lit. 'job control language')
- X
- jclfile file containing jcl.
- X
- jj Job jump, program to reorder jobs in a queue.
- X
- jk Job kill, program to remove jobs from a queue.
- X
- jm Job monitor, program to add or change the monitor
- X specification for a job in a queue.
- X
- jn Job name, program to add or change the namestring
- X of a job in the queue.
- X
- jobcount The number of jobs in a given queue.
- X
- jobdone A script used to notify the submittor when a job
- X has finished processing.
- X
- jobname A meaningful name assigned to and stored with an
- X entry for a job in a queue.
- X
- jobno see entryno.
- X
- jr Job repeat, program to cause the currently running
- X job in a queue to be rerun when it terminates.
- X
- js Job submit, Program to submit jobs to a queue for
- X queued processing.
- X
- MANDIR The directory path specified in the Makefile, where
- X the manual pages will be installed.
- X
- monitor The output (stdout and stderr) of jobs processed in
- X QBATCH queues.
- X
- monitorspec The pathspec to which a monitor will be written.
- X
- namestring see jobname.
- X
- prioritise To alter the scheduling priority of jobs (nice value)
- X by altering the priority field in the queue header.
- X
- qa Queue access, script to list queues to which a user
- X has submit access.
- X
- qBq Magic word present in all QBATCH queues to identify
- X them as such.
- X
- qc Queue create, program to create QBATCH queues.
- X
- QCONTEXT Fixed context queue directive indicating the uid
- X (and gid) under which the job will run.
- X
- qd Queue disable, Program to prevent further submissions
- X to a queue.
- X
- qe Queue enable, program to enable submissions to queue.
- X
- QENTRY Environment variable initialised by qp, contains the
- X entryno of this job.
- X
- qf Queue find, program to display information about a queue.
- X
- qg Queue go, program to resume processing after a queue halt.
- X
- QGETENV Fixed context queue directive indicating an environment
- X variable to be copied to the environment of the job.
- X
- QGROUPS Fixed context queue directive indicating a list of groups
- X permitted to submit jobs to this queue.
- X
- qh Queue halt, program to suspend processing of the current
- X job in a queue.
- X
- ql Queue list, program to list the contents of a queue.
- X
- qp Queue process, program to initiate processing of jobs
- X in a queue.
- X
- qs Queue stop. program to stop further jobs being processed
- X in a queue.
- X
- qt Queue test, program to test and return queue status.
- X
- queuename
- qname Name of a file in QUEUEPATH which is a QBATCH queue.
- X
- QUEUEPATH The directory path specified in the Makefile where
- X QBATCH queues will be created and used.
- X
- QUSERS Fixed context queue directive indicating a list of
- X users permitted to submit jobs to this queue.
- X
- qw Queue wait, program which waits until a queue is idle.
- X
- qxenv File in QUEUEPATH containing a list of environment
- X variables which are NOT to be transferred to the
- X environment of a job.
- X
- SPOOLPATH The directory path specified in the Makefile, where
- X js will create jcl files, and where qp will read them.
- X
- submittor The user submitting a job to a queue.
- END_OF_FILE
- if test 3787 -ne `wc -c <'doc/glossary'`; then
- echo shar: \"'doc/glossary'\" unpacked with wrong size!
- fi
- # end of 'doc/glossary'
- fi
- if test -f 'man/js.l' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man/js.l'\"
- else
- echo shar: Extracting \"'man/js.l'\" \(4394 characters\)
- sed "s/^X//" >'man/js.l' <<'END_OF_FILE'
- X.TH JS 1L "14 May 1991" JS "QUEUED BATCH PROCESSING SYSTEM"
- X.SH COPYRIGHT
- The
- X.B QBATCH
- system and its related programs are Copyright:
- X.br
- X(c) Vita Services Ltd. 1990
- X.br
- X(c) Vita Fibres Ltd. 1991
- X.SH NAME
- X.B js
- X\- job submit. submit a job to an named queue.
- X.SH SYNOPSIS
- X.B js
- X[
- X.B \-dl
- X]
- X[
- X.BI \-m " monitor"
- X]
- X[
- X.BI \-n " jobname"
- X]
- X[
- X.BI \-r " reply"
- X]
- X.br
- X[
- X.BI \-s " shell"
- X]
- X.B queuename
- X[
- X.B jclfile
- X]
- X|[
- X.BI \-v
- X]
- X.SH DESCRIPTION
- A temporary file is created in the spooling directory specified in the
- queue header. If the queue is not a fixed context queue, the current
- environment of the user is copied into it, certain environment
- variables may be excluded from this copy if they are listed in a .qxenv
- file in the directory containing the queuefiles. If the queue is fixed context, jcl is
- generated to provide an environment and context as specified in the rc
- file for the queue. If the jcl file is provided, either a line of jcl
- containing the pathspec of it is placed in the temporary file (-l
- option), or it's contents are copied into the temporary file. If the
- jcl file is not provided, stdin is copied into the temporary file up to
- an eof. (this allows for piped jcl). An entry is added to the end of
- the queue file, and if the queue is being processed, a signal is sent
- to the pid of the process engine for the queue.
- X.SH OPTIONS
- X.TP 12
- X.B \-d
- Debug. Creates the job file with the -x switch set so that
- the monitor echoes all commands as they are executed (silently
- ignored if a shell is specified with the -s option).
- X.TP
- X.B \-l
- Link. Do not copy the jcl file into the spool directory.
- Instead, create a smaller jcl file containing a call to it.
- This allows large jcl files to be processed without taking
- too much disk space.
- X.br
- NOTE: Because js needs to create the jcl file to set up the environment for the job,
- X(and possible script commands and directives in the case of fixed context queues), jcl
- linked in this way must be totally self-contained. The environment is NOT copied in the case
- of a linked job, and this option is not permitted for fixed context queues.
- X.TP
- X.BI \-m " monitor"
- Specify a non-default monitor for this job. If this
- is not specified, the monitor (stdout and stderr) for the
- job will be that specified in the queue header. If the
- monitor specified here is a path rather than a file, the
- filename xxxx.mon will be used in that path, where xxxx
- is the first four characters of the queue name.
- X.TP
- X.BI \-n " jobname"
- Specify a descriptive name for this job, which will
- be displayed when ql is run.
- X.br
- NOTE: If a name is not specified for a given job, js
- will assume that the job is being submitted through
- a batch process, and will use the first 30 bytes of the LAST
- line of the jcl as the job name. Normally, if this
- is the case, the jcl will only consist of a single line
- X(a macro call) and this default will include the macro
- name. If the jcl consists of more than one line (after
- setting up the job environment), it is recommended that
- an additional (comment) line is added at the end, to
- generate a meaningful job name.
- X.TP
- X.BI \-r " n"
- Reply. Notify the user when the job is finished.
- n may have one of the following values:
- X.nf
- X0 No reply required. (the default).
- X1 Write a message on the users tty.
- X2 Send mail to the user.
- X.fi
- Any other value results in NO notification.
- X.TP
- X.BI \-s " shell"
- Specify the shell under which the batch job is run. This should
- be the full pathspec of the executable file which will be run
- to interpret this jcl script. If the executable requires arguments
- the group of path and arguments should be surrounded by quotes.
- When a shell (possibly including switches or arguments) is specified,
- the debug (-d) switch is silently ignored (it is specific to the Bourne shell).
- X.br
- If the queue is a fixed context queue, and the first line of the control file
- starts with '#!/' (i.e. is a directive to use a particular shell) then the -s
- option is silently ignored.
- X.br
- eg. -s "/bin/sh -x"
- X.TP
- X.BI \-v
- Display QBATCH version and copyright information.
- X.SH FILES
- X.ft B
- QUEUEPATH/<queue files>
- QUEUEPATH/.qxenv
- X.SH "SEE ALSO"
- X.BR qbatch (1L)
- X.BR jj (1L)
- X.BR jk (1L)
- X.BR jm (1L)
- X.BR jn (1L)
- X.BR jr (1L)
- X.BR qa (1L)
- X.BR qc (8L)
- X.BR qd (1L)
- X.BR qe (1L)
- X.BR qf (1L)
- X.BR qg (1L)
- X.BR qh (1L)
- X.BR ql (1L)
- X.BR qp (1L)
- X.BR qs (1L)
- X.BR qt (1L)
- X.BR qw (1L)
- X.BR rc.QBATCH (8L)
- X.BR jobdone (8L)
- X.BR queue (5L)
- X.BR qxenv (5L)
- END_OF_FILE
- if test 4394 -ne `wc -c <'man/js.l'`; then
- echo shar: \"'man/js.l'\" unpacked with wrong size!
- fi
- # end of 'man/js.l'
- fi
- if test -f 'man/qf.l' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man/qf.l'\"
- else
- echo shar: Extracting \"'man/qf.l'\" \(3581 characters\)
- sed "s/^X//" >'man/qf.l' <<'END_OF_FILE'
- X.TH QF 1L "14 May 1991" QF "QUEUED BATCH PROCESSING SYSTEM"
- X.SH COPYRIGHT
- The
- X.B QBATCH
- system and its related programs are Copyright:
- X.br
- X(c) Vita Services Ltd. 1990
- X.br
- X(c) Vita Fibres Ltd. 1991
- X.SH NAME
- X.B qf
- X\- Queue find. Find out information about the named queue.
- X.SH SYNOPSIS
- X.B qf
- X\-[
- X.B a
- X]|[
- X.B l
- X]|[
- X.B n
- X]|[
- X.B p
- X]|[
- X.B q
- X]|[
- X.B r
- X]|[
- X.B s
- X]
- X.B qname
- X.br
- X.B qf
- X[
- X.BI \-e " entryno"
- X] [ -[
- X.B j
- X]|[
- X.B m
- X]]
- X.B qname
- X.br
- X.B qf
- X[
- X.BI \-v
- X]
- X.SH DESCRIPTION
- This function is provided for the convenience of the
- user, in that frequently this information is needed
- in order to examine job monitors, or jcl files. Rather
- than having to determine this information in some other
- way (ql for example), and then enter it manually, The
- shell facilities of UNIX can be utilised viz:
- X.br
- tail `qf -m sopt`
- X.br
- or vi `qf -e7 work`
- X.SH OPTIONS
- X.TP 12
- X.B \-a
- Activity. Actually reports back the number of entries
- in the queue on stdout. As with the p option,
- this is used in rc.QBATCH to determine whether there
- was a job in the queue at closedown. If there was,
- rc.QBATCH will sleep for 20 seconds after restarting
- the process engine, to allow jobs to process to a 'settled'
- state before processing any other queues.
- X.TP
- X.BI \-e " n"
- XEntry no <n>. modifies the action of -m and -j to report
- either the monitor or jcl file of queue entry no n.
- X.TP
- X.B \-j
- JCL. Reports the full pathspec of the JCL file of the
- first entry in the queue. (Normally the running job.)
- X.TP
- X.B \-l
- Line. Produces a brief status report on the queue header. The report is headed with the
- field descriptions and consists a single line of data.
- X.RS -6
- viz:
- X
- X.nf
- Queue No of Priority Fixed Enabled Halted Stopped
- Name Entries (nice) Context
- X
- sopt 0 0 no yes no no
- X
- X.RE
- X.fi
- The similar (-l) option to qt is identical but without the headings.
- X.TP 12
- X.B \-m
- Monitor. Reports the full pathspec of the monitor in
- use or to be used by the first job in the queue.
- X.TP
- X.B \-n
- Nice value. Reports the priority or nice value stored in the queue header.
- X.TP
- X.B \-p
- PID. Reports the pid stored in the queue header. This
- is normally either the pid of the queue process
- engine activity, or zero if the queue is stopped.
- The exception is when the queue has stopped processing
- abnormally (i.e without being stopped with qs), usually
- by a system shutdown. Then there will be a pid stored,
- but there will be no process activity. Like the -a option, this is used
- by rc.QBATCH to determine if a queue was being processed
- when the system was closed down. If it was, rc.QBATCH will start a new
- process engine.
- X.TP
- X.B \-q
- Queue default monitor. Reports the full pathspec of
- the default monitor.
- X.TP
- X.B \-r
- Running job. Reports the pid of the currently running job.
- X.TP
- X.B \-s
- Summary timings. Reports a brief summary of the activity of the queue, both as total time
- taken , and as average per job. The times reported are Queued (time on queue before being
- processed) real (wall clock), user, and system cpu time. They are reported as DD:HH:MM:SS.ss.
- If the queue is being processed when
- X.B qf
- is run, it will also report queue utilisation as a percentage of availability.
- X.TP
- X.B \-v
- Display QBATCH version and copyright information.
- X.SH FILES
- X.ft B
- QUEUEPATH/*
- X.SH "SEE ALSO"
- X.BR qbatch (1L)
- X.BR jj (1L)
- X.BR jk (1L)
- X.BR jm (1L)
- X.BR jn (1L)
- X.BR jr (1L)
- X.BR js (1L)
- X.BR qa (1L)
- X.BR qc (8L)
- X.BR qd (1L)
- X.BR qe (1L)
- X.BR qg (1L)
- X.BR qh (1L)
- X.BR ql (1L)
- X.BR qp (1L)
- X.BR qs (1L)
- X.BR qt (1L)
- X.BR qw (1L)
- X.BR rc.QBATCH (8L)
- X.BR jobdone (8L)
- X.BR queue (5L)
- X.BR qxenv (5L)
- END_OF_FILE
- if test 3581 -ne `wc -c <'man/qf.l'`; then
- echo shar: \"'man/qf.l'\" unpacked with wrong size!
- fi
- # end of 'man/qf.l'
- fi
- if test -f 'man/qt.l' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man/qt.l'\"
- else
- echo shar: Extracting \"'man/qt.l'\" \(2882 characters\)
- sed "s/^X//" >'man/qt.l' <<'END_OF_FILE'
- X.TH QF 1L "14 May 1991" QF "QUEUED BATCH PROCESSING SYSTEM"
- X.SH COPYRIGHT
- The
- X.B QBATCH
- system and its related programs are Copyright:
- X.br
- X(c) Vita Services Ltd. 1990
- X.br
- X(c) Vita Fibres Ltd. 1991
- X.SH NAME
- X.B qt
- X\- Queue test. Test various aspects of the queue status.
- X.SH SYNOPSIS
- X.B qt
- X\-[
- X.B e
- X]|[
- X.B f
- X]|[
- X.B h
- X]|[
- X.B k
- X]|[
- X.B l
- X]|[
- X.B r
- X]|[
- X.B s
- X]|[
- X.B t
- X]|[
- X.B u
- X]
- X.B qname
- X.br
- X.B qt
- X[
- X.BI \-v
- X]
- X.SH DESCRIPTION
- This function is provided for use in scripts.
- X.B qt
- will either fail, or not fail depending on the result of the test carried out.
- Most tests (except -t and -u) simply check whether one of the header flags is set.
- X.SH OPTIONS
- X.TP 12
- X.B \-e
- XEnabled flag.
- X.B qt
- will fail if the enabled flag is not set.
- X(queue is not accepting entries) it will not fail if the queue is accepting entries.
- X.TP
- X.B \-f
- XFixed context flag.
- X.B qt
- will fail if the fixed context flag is not set.
- X(queue is not fixed context) It will not fail if the queue is fixed context.
- X.TP
- X.B \-h
- Halt flag.
- X.B qt
- will fail if the halt flag is not set.
- X(Current job is not halted) It will not fail if the job is halted.
- X.TP
- X.B \-k
- Kill flag.
- X.B qt
- will fail if the kill flag is not set.
- X(last job was not killed) It will not fail if the last job was killed.
- X.TP
- X.B \-l
- Line. Produces a brief single line status report on the queue header if the user may submit jobs
- to this queue. (see -u option) This is mainly included for use by the qa script (qv).
- X.RS -6
- viz:
- X.nf
- X
- sopt 0 0 no yes no no
- X
- X.RE
- X.fi
- The similar (-l) option to qf is identical but with headings for the columns.
- X.TP
- X.B \-r
- Repeat flag.
- X.B qt
- will fail if the repeat flag is not set.
- X(current job is not to be repeated) It will not fail if the job is to be (is being) repeated)
- X.TP
- X.B \-s
- stop flag.
- X.B qt
- will fail if the stop flag is not set.
- X(queue will not stop after current job) It will not fail if the queue will stop after the
- current job or is already stopped.
- X.TP
- X.B \-t
- Test queue.
- X.B qt
- will fail if the queue is not a valid
- X.B QBATCH
- queue.
- X.TP
- X.B \-u
- Use (can I?)
- X.B qt
- Tests the accessibility of the queue for the currently logged in user context.
- If the queue is not fixed context, or if this user can submit jobs to this fixed context queue,
- X.B qt
- will not fail.
- X.B qt
- will fail if this queue is a fixed context queue, and this user's uid or gid do not appear
- in a #QUSERS or #QGROUPS directive for this queue (if these directives exist for this queue)
- X.B qt
- X.TP
- X.B \-v
- Display QBATCH version and copyright information.
- X.SH FILES
- X.ft B
- QUEUEPATH/*
- X.SH "SEE ALSO"
- X.BR qbatch (1L)
- X.BR jj (1L)
- X.BR jk (1L)
- X.BR jm (1L)
- X.BR jn (1L)
- X.BR jr (1L)
- X.BR js (1L)
- X.BR qa (1L)
- X.BR qc (8L)
- X.BR qd (1L)
- X.BR qe (1L)
- X.BR qf (1L)
- X.BR qg (1L)
- X.BR qh (1L)
- X.BR ql (1L)
- X.BR qp (1L)
- X.BR qs (1L)
- X.BR qt (1L)
- X.BR qw (1L)
- X.BR rc.QBATCH (8L)
- X.BR jobdone (8L)
- X.BR queue (5L)
- X.BR qxenv (5L)
- END_OF_FILE
- if test 2882 -ne `wc -c <'man/qt.l'`; then
- echo shar: \"'man/qt.l'\" unpacked with wrong size!
- fi
- # end of 'man/qt.l'
- fi
- if test -f 'man/queue.l' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man/queue.l'\"
- else
- echo shar: Extracting \"'man/queue.l'\" \(3956 characters\)
- sed "s/^X//" >'man/queue.l' <<'END_OF_FILE'
- X.TH QUEUE 5L "11 May 1991" QUEUE "QUEUED BATCH PROCESSING SYSTEM"
- X.SH COPYRIGHT
- The
- X.B QBATCH
- system and its related programs are Copyright:
- X.br
- X(c) Vita Services Ltd. 1990
- X.br
- X(c) Vita Fibres Ltd. 1991
- X.SH NAME
- X.B queue
- X\- Description of a qbatch queue file.
- X.SH SYNOPSIS
- X.ft B
- X#include "qbatch.h"
- X.SH DESCRIPTION
- A queue is a file used by the
- X.B QBATCH
- system to store information about the queue and it's process engine, and about
- jobs queued therein. The queue has two parts. The header contains the variable data
- and defaults for the queue:
- X.sp
- X.nf
- X
- struct queue_header {
- X char q_magic[4];
- X pid_t qh_pid;
- X int qh_noentries;
- X int qh_hiwater;
- X int qh_priority;
- X unsigned int qh_flags;
- X time_t qh_proc;
- X time_t qh_start;
- X time_t qh_queued;
- X long qh_real;
- X long qh_user;
- X long qh_system;
- X long qh_jobcount;
- X char qh_spool[64];
- X char qh_defmon[64];
- X};
- X.fi
- X.sp
- XField contents are :
- X.TP 15
- X.B q_magic
- Identification of a queue.
- X.TP
- X.B qh_pid
- Process id of the qp activity handling this queue.
- X.TP
- X.B qh_noentries
- current number of entries
- X.TP
- X.B qh_hiwater
- highest job entry number in queue
- X.TP
- X.B qh_priority
- Priority or 'nice' value of process
- X.TP
- X.B qh_flags
- qh_flags is a bit encoded unsigned integer.
- If qh_flags masked with the defined valued below is greater than zero,
- the flag is set.
- X.TP
- X.B qh_proc
- time queue started processing
- X.TP
- X.B qh_start
- time current job started
- X.TP
- X.B qh_queued
- Total time spent queued (before processing)
- X.TP
- X.B qh_real
- total process time for jobs in this queue
- X.TP
- X.B qh_user
- total user CPU time for jobs in this queue
- X.TP
- X.B qh_system
- total system CPU time for jobs in this queue
- X.TP
- X.B qh_jobcount
- total no of jobs processed
- X.TP
- X.B qh_spool
- spool file directory for this queue
- X.br
- X(default is /usr/spool)
- X.TP
- X.B qh_defmon
- default monitor for queue
- X.br
- X(default is <qh_spool>/<qname>.mon)
- X.sp 2
- X.TP 0
- X.nf
- Bitmap of qh_flags:
- X.sp
- X#define qh_repeat 1 /* repeat current job flag */
- X#define qh_kill 2 /* kill current job flag */
- X#define qh_stop 4 /* stop processing flag */
- X#define qh_enabled 8 /* accept entries flag */
- X#define qh_halt 16 /* suspend processing flag */
- X#define qh_fixed 32 /* fixed context processing */
- X#define qh_flagmax 32 /* should be highest above */
- X#define qh_action qh_kill + qh_halt /* immediate action flags */
- X.sp 2
- X.fi
- The header is followed by a variable number of queue entries (as defined in
- qh_noentries), one for each job in the queue:
- X.sp
- X.nf
- struct queue_entry {
- X int qe_jobno;
- X int qe_status;
- X int qe_repcount;
- X int qe_notify;
- X uid_t qe_uid;
- X gid_t qe_gid;
- X time_t qe_submitted;
- X char qe_uname[16];
- X char qe_tty[8];
- X char qe_jobname[32];
- X char qe_jcl[64];
- X char qe_monitor[64];
- X};
- X.fi
- X.TP 15
- X.B qe_jobno
- identifier for this job
- X.TP
- X.B qe_status
- flag set (to it's pid) if this job is
- running
- X.TP
- X.B qe_repcount
- internal flag for environment
- X.TP
- X.B qe_notify
- notification flag:
- X.br
- X.nf
- X0 = none
- X1 = display message
- X2 = mail
- X.fi
- X.TP
- X.B qe_uid
- uid of activity submitting this job
- X.TP
- X.B qe_gid
- gid of activity submitting this job
- X.TP
- X.B qe_submitted
- time this job was submitted
- X.TP
- X.B qe_uname
- user name of submittor
- X.TP
- X.B qe_tty
- user's terminal if interactive
- X.TP
- X.B qe_jobname
- optional user job name
- X.TP
- X.B qe_jcl
- filename of job file submitted
- X.TP
- X.B qe_monitor
- monitor file for this job if not
- default
- X.SH OPTIONS
- X.SH FILES
- X.ft B
- QUEUEPATH/*
- X.SH "SEE ALSO"
- X.BR qbatch (1L)
- X.BR jj (1L)
- X.BR jk (1L)
- X.BR jm (1L)
- X.BR jn (1L)
- X.BR jr (1L)
- X.BR js (1L)
- X.BR qa (1L)
- X.BR qc (8L)
- X.BR qd (1L)
- X.BR qe (1L)
- X.BR qf (1L)
- X.BR qg (1L)
- X.BR qh (1L)
- X.BR ql (1L)
- X.BR qp (1L)
- X.BR qt (1L)
- X.BR qs (1L)
- X.BR qw (1L)
- X.BR rc.QBATCH (8L)
- X.BR jobdone (8L)
- X.BR qxenv (5L)
- END_OF_FILE
- if test 3956 -ne `wc -c <'man/queue.l'`; then
- echo shar: \"'man/queue.l'\" unpacked with wrong size!
- fi
- # end of 'man/queue.l'
- fi
- if test -f 'src/jm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/jm.c'\"
- else
- echo shar: Extracting \"'src/jm.c'\" \(3130 characters\)
- sed "s/^X//" >'src/jm.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* jm .. job monitor. Add or alter monitor for a given job */
- X/* */
- X/* usage: jn [-e<entryno>] qname namestring */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X
- X#include "qbatch.h"
- int fpq = 0;
- int j, entryno = 0;
- uid_t uid;
- int changed = 0;
- char *queuename;
- char queue[128];
- char buff [128];
- X#include "config.h"
- X
- main (argc, argv, envp)
- int argc;
- char *argv[], *envp[];
- X{
- X int c;
- X extern char *optarg;
- X extern int optind;
- X while ((c = getopt (argc, argv, "e:v")) != -1)
- X switch (c)
- X {
- X case 'e': entryno = atoi (optarg);
- X break;
- X case 'v': q_version();
- X case '?': qb_term (-1);
- X }
- X if (optind >= argc)
- X {
- X fprintf(stderr,"Usage: jm -e<entryno> queuename monitorspec\n");
- X exit (-1);
- X }
- X queuename = argv[optind];
- X strcpy (queue, QUEUEPATH);
- X strcat (queue, queuename);
- X qb_setterm();
- X fpq = open (queue, O_RDWR);
- X if (fpq == -1)
- X {
- X fprintf (stderr, "Invalid queue name: %s\n", queuename);
- X qb_term (-1);
- X }
- X optind ++;
- X if (argc <= optind)
- X {
- X fprintf (stderr, "Missing monitor path\n");
- X qb_term (-1);
- X }
- X argv[optind][63] = 0;
- X q_lock(fpq);
- X read (fpq, &head, sizeof(head));
- X if (bad_queue()) qb_exit(-1);
- X j = lseek (fpq, 0, SEEK_CUR);
- X read (fpq, &entry, sizeof(entry));
- X uid = geteuid();
- X if (uid != 0 && uid != entry.qe_uid)
- X {
- X fprintf (stderr, "Must own the job or be super user to change monitor\n");
- X qb_term (-1);
- X }
- X if (entryno != 0 && entryno != entry.qe_jobno)
- X {
- X while (entryno != entry.qe_jobno)
- X {
- X j = lseek (fpq, 0, SEEK_CUR);
- X read (fpq, &entry, sizeof(entry));
- X }
- X }
- X if (strcmp (entry.qe_monitor, argv[optind]) != 0) changed ++; /* changed monitor */
- X if (entry.qe_status != 0) /* job active */
- X {
- X if (changed)
- X {
- X if ((head.qh_flags &qh_repeat) == 0) head.qh_flags += qh_repeat;
- X if ((head.qh_flags &qh_kill) == 0) head.qh_flags += qh_kill;
- X }
- X }
- X strcpy (entry.qe_monitor, argv[optind]);
- X lseek (fpq, 0, SEEK_SET);
- X write (fpq, &head, sizeof(head));
- X lseek (fpq, j, SEEK_SET);
- X write (fpq, &entry, sizeof(entry));
- X if (changed) printf ("Monitor redirected to %s\n", entry.qe_monitor);
- X else printf ("Monitor unchanged\n");
- X fflush (stdout);
- X q_unlock(fpq);
- X close(fpq); fpq = 0;
- X tell_qp();
- X qb_term(0);
- X}
- END_OF_FILE
- if test 3130 -ne `wc -c <'src/jm.c'`; then
- echo shar: \"'src/jm.c'\" unpacked with wrong size!
- fi
- # end of 'src/jm.c'
- fi
- if test -f 'src/jn.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/jn.c'\"
- else
- echo shar: Extracting \"'src/jn.c'\" \(2563 characters\)
- sed "s/^X//" >'src/jn.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* jn .. job name. Add or alter name for a given job */
- X/* */
- X/* usage: jn [-e<entryno>] qname namestring */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X
- X#include "qbatch.h"
- int fpq = 0;
- int j, entryno = 0;
- uid_t uid;
- char *queuename;
- char queue[128];
- char buff [128];
- X#include "config.h"
- X
- X
- main (argc, argv)
- int argc;
- char *argv[];
- X{
- X int c;
- X extern char *optarg;
- X extern int optind;
- X while ((c = getopt (argc, argv, "e:v")) != -1)
- X switch (c)
- X {
- X case 'e': entryno = atoi (optarg);
- X break;
- X case 'v': q_version();
- X case '?': qb_term (-1);
- X }
- X if (optind >= argc)
- X {
- X fprintf (stderr, "Usage: jn [-e<entryno>] qname namestring\n");
- X exit (-1);
- X }
- X queuename = argv[optind];
- X strcpy (queue, QUEUEPATH);
- X strcat (queue, queuename);
- X qb_setterm();
- X fpq = open (queue, O_RDWR);
- X if (fpq == -1)
- X {
- X fprintf (stderr, "Invalid queue name: %s\n", queuename);
- X qb_term (-1);
- X }
- X optind ++;
- X if (argc <= optind)
- X {
- X fprintf (stderr, "Missing job name\n");
- X qb_term (-1);
- X }
- X argv[optind][30] = 0;
- X q_lock(fpq);
- X read (fpq, &head, sizeof(head));
- X if (bad_queue()) qb_exit(-1);
- X j = lseek (fpq, 0, SEEK_CUR);
- X read (fpq, &entry, sizeof(entry));
- X uid = geteuid();
- X if (uid != 0 && uid != entry.qe_uid)
- X {
- X fprintf (stderr, "Must own the job or be super user to name it\n");
- X qb_term (-1);
- X }
- X if (entryno != 0 && entryno != entry.qe_jobno)
- X {
- X while (entryno != entry.qe_jobno)
- X {
- X j = lseek (fpq, 0, SEEK_CUR);
- X read (fpq, &entry, sizeof(entry));
- X }
- X }
- X strcpy (entry.qe_jobname, argv[optind]);
- X lseek (fpq, 0, SEEK_SET);
- X write (fpq, &head, sizeof(head));
- X lseek (fpq, j, SEEK_SET);
- X write (fpq, &entry, sizeof(entry));
- X q_unlock(fpq);
- X close (fpq); fpq = 0;
- X qb_term(0);
- X}
- END_OF_FILE
- if test 2563 -ne `wc -c <'src/jn.c'`; then
- echo shar: \"'src/jn.c'\" unpacked with wrong size!
- fi
- # end of 'src/jn.c'
- fi
- if test -f 'src/qbatch.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/qbatch.h'\"
- else
- echo shar: Extracting \"'src/qbatch.h'\" \(3583 characters\)
- sed "s/^X//" >'src/qbatch.h' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* qbatch.h qbatch local header file */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X#include <stdio.h>
- X#include <string.h>
- X#include <sys/file.h>
- X#include <sys/types.h>
- X#include <unistd.h>
- X
- X#include "patchlevel.h"
- X#include "what.h"
- static char QbCR1 []= "@(#) Copyright (c) Vita Services 1990";
- static char QbCR2 []= "@(#) (c) Vita Fibres 1990 1991";
- X
- X/* structure of flag byte */
- X#define qh_repeat 1 /* repeat current job flag */
- X#define qh_kill 2 /* kill current job flag */
- X#define qh_stop 4 /* stop processing flag */
- X#define qh_enabled 8 /* accept entries flag */
- X#define qh_halt 16 /* suspend processing flag */
- X#define qh_fixed 32 /* fixed context processing */
- X#define qh_flagmax 32 /* should be highest above */
- X#define qh_action qh_kill + qh_halt /* immediate action flags */
- X
- struct queue_header {
- X char q_magic[4];
- X pid_t qh_pid; /* Process id of the qp activity
- X handling this queue. */
- X int qh_noentries; /* current number of entries */
- X int qh_hiwater; /* highest jobid in queue */
- X int qh_priority; /* 'nice' value of process */
- X unsigned int qh_flags; /* see above */
- X time_t qh_proc; /* time queue started processing */
- X time_t qh_start; /* time current job started */
- X time_t qh_queued; /* Total time spent queued (before processing) */
- X long qh_real; /* total process time for jobs in this queue */
- X long qh_user; /* total user CPU time for jobs in this queue */
- X long qh_system; /* total system CPU time for jobs in this queue */
- X long qh_jobcount; /* total no of jobs processed */
- X char qh_spool[64]; /* spool file directory for this queue
- X (default is /usr/spool) */
- X char qh_defmon[64]; /* default monitor for queue
- X (default is <qh_spool>/<qname>.mon) */
- X};
- X
- struct queue_entry {
- X int qe_jobno; /* identifier for this job */
- X pid_t qe_status; /* flag set (to it's pid) if this job is
- X running */
- X int qe_repcount; /* internal flag for environment */
- X int qe_notify; /* notification flag .. 0 = none */
- X /* 1 = display message, 2 = mail */
- X uid_t qe_uid; /* uid of activity submitting this job */
- X gid_t qe_gid; /* gid of activity submitting this job */
- X time_t qe_submitted; /* time this job was submitted */
- X char qe_uname[16]; /* user name of submittor */
- X char qe_tty[8]; /* user's terminal if interactive */
- X char qe_jobname[32]; /* optional user job name */
- X char qe_jcl[64]; /* filename of job file submitted */
- X char qe_monitor[64]; /* monitor file for this job if not
- X default */
- X};
- struct queue_header head;
- struct queue_entry entry;
- void qb_term();
- void qb_exit();
- void tell_qp();
- void q_lock();
- void q_unlock();
- void qb_setterm(); void handle_flags();
- void qb_setgrp();
- void kill_child_group();
- void toggle_halt_status();
- END_OF_FILE
- if test 3583 -ne `wc -c <'src/qbatch.h'`; then
- echo shar: \"'src/qbatch.h'\" unpacked with wrong size!
- fi
- # end of 'src/qbatch.h'
- fi
- if test -f 'src/qs.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/qs.c'\"
- else
- echo shar: Extracting \"'src/qs.c'\" \(2998 characters\)
- sed "s/^X//" >'src/qs.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* qs .. queue stop. Set the stop flag for a given queue so that qp */
- X/* terminates when current job is finished. */
- X/* (optionally to kill or repeat and kill current job)*/
- X/* */
- X/* usage: qs [-k] [-r] [-w] qname */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X
- X#include "qbatch.h"
- X
- int fpq = 0;
- int kflag = 0, rflag = 0, wflag = 0;
- char *queuename;
- char queue[128];
- char buff [128];
- X#include "config.h"
- X
- void qwait()
- X{
- X do
- X {
- X fpq = open (queue, O_RDWR);
- X q_lock(fpq);
- X read (fpq, &head, sizeof(head));
- X q_unlock(fpq);
- X close (fpq);fpq = 0;
- X if (head.qh_pid == 0) break;
- X sleep (30);
- X }
- X while (head.qh_pid != 0);
- X
- X exit (0);
- X}
- X
- main (argc, argv, envp)
- int argc;
- char *argv[], *envp[];
- X{
- X int c;
- X extern char *optarg;
- X extern int optind;
- X if (getuid() != 0)
- X {
- X fprintf (stderr, "Must be root to stop a queue\n");
- X exit (-1);
- X }
- X while ((c = getopt (argc, argv, "krwv")) != -1)
- X switch (c)
- X {
- X case 'k': kflag = 1;
- X break;
- X case 'r': rflag = 1;
- X kflag ++;
- X break;
- X case 'w': wflag = 1;
- X break;
- X case 'v': q_version();
- X }
- X if (optind >= argc)
- X {
- X fprintf(stderr, "Usage : qs <qname>\n");
- X exit (-1);
- X }
- X queuename = argv[optind];
- X strcpy (queue, QUEUEPATH);
- X strcat (queue, queuename);
- X qb_setterm();
- X fpq = open (queue, O_RDWR);
- X q_lock(fpq);
- X read (fpq, &head, sizeof(head));
- X if (bad_queue()) qb_exit(-1);
- X if (head.qh_noentries > 0) read (fpq, &entry, sizeof(entry));
- X if ((head.qh_flags & qh_stop) > 0)
- X {
- X if (wflag == 0)
- X {
- X fprintf (stderr, "Queue %s is already stopped!\n", queue);
- X qb_exit(-1);
- X }
- X else qwait();
- X }
- X head.qh_flags ^= qh_stop;
- X if (rflag)
- X {
- X if ((head.qh_flags&qh_repeat) == 0)
- X {
- X head.qh_flags += qh_repeat;
- X }
- X }
- X if (rflag || kflag)
- X {
- X if ((head.qh_flags&qh_kill) == 0)
- X {
- X head.qh_flags += qh_kill;
- X }
- X }
- X lseek (fpq, 0, SEEK_SET);
- X write (fpq, &head, sizeof(head));
- X q_unlock(fpq);
- X close (fpq);fpq = 0;
- X tell_qp();
- X if (wflag != 0) qwait();
- X qb_term (0);
- X}
- END_OF_FILE
- if test 2998 -ne `wc -c <'src/qs.c'`; then
- echo shar: \"'src/qs.c'\" unpacked with wrong size!
- fi
- # end of 'src/qs.c'
- fi
- if test -f 'src/qt.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/qt.c'\"
- else
- echo shar: Extracting \"'src/qt.c'\" \(4128 characters\)
- sed "s/^X//" >'src/qt.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* qf .. queue find. Report information about a queue */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X
- X#include <stdlib.h>
- X#include "qbatch.h"
- char buff[128];
- XFILE *fpq;
- char *queuename;
- char *fcptr;
- char rcmd[128];
- int qpuid[10];
- int qpgid[10];
- int permission, fixedcontext;
- int jobuid, jobgid;
- int i,j;
- int c;
- void q_version()
- X{
- X puts (&QbSID[5]);
- X puts ("");
- X puts (&QbCR1[5]);
- X puts (&QbCR2[5]);
- X puts ("");
- X exit(0);
- X}
- int bad_queue()
- X{
- X if (strcmp (head.q_magic, "qBq") != 0)
- X {
- X if (c != 'U') fprintf(stderr,"%s is not a valid QBATCH queue\007\n", queuename);
- X return(-1);
- X }
- X return(0);
- X}
- void usage()
- X{
- X puts("Usage: qt -[e]|[f]|[h]|[k]|[r]|[s]|[u]|[t]|[v] <queuename>");
- X exit (0);
- X}
- void ext(flag)
- int flag;
- X{
- X exit ((flag == 0)?1:0);
- X}
- void do_list()
- X{
- X printf("%-8s %6d ", queuename, head.qh_noentries);
- X printf("%6d ", head.qh_priority);
- X printf("%s ",(head.qh_flags&qh_fixed)?"yes": "no ");
- X printf("%s ",(head.qh_flags&qh_enabled)?"yes": "no ");
- X printf("%s ",(head.qh_flags&qh_halt)?"yes": "no ");
- X printf("%s\n", (head.qh_flags&qh_stop)?"yes": "no ");
- X}
- main (argc, argv)
- int argc;
- char *argv[];
- X{
- X extern char *optarg;
- X extern int optind;
- X if ((c = getopt (argc, argv, "efhklrstuv")) == -1) usage();
- X if (c == 'v') q_version();
- X if (optind >= argc)
- X {
- X fprintf (stderr, "Invalid or missing queue name!\n");
- X exit (-1);
- X }
- X queuename = argv[optind];
- X strcpy (buff, QUEUEPATH);
- X strcat (buff, queuename);
- X fpq = fopen (buff, "r");
- X if (fpq == NULL)
- X {
- X fprintf (stderr, "Invalid queue name: %s!\n",queuename);
- X fclose (fpq);
- X exit (-1);
- X }
- X fread (&head, sizeof(head), 1, fpq);
- X if (bad_queue())
- X {
- X fclose (fpq);
- X exit (-1);
- X }
- X fclose (fpq);
- X switch (c)
- X {
- X case 't': exit (0);
- X case 'e': ext (head.qh_flags & qh_enabled);
- X case 'f': ext (head.qh_flags & qh_fixed);
- X case 'h': ext (head.qh_flags & qh_halt);
- X case 'k': ext (head.qh_flags & qh_kill);
- X case 'r': ext (head.qh_flags & qh_repeat);
- X case 's': ext (head.qh_flags & qh_stop);
- X }
- X /* done the rest, must be -u or -l*/
- X if ((head.qh_flags & qh_fixed) == 0)
- X {
- X /* not fixed context, anyone can use */
- X if (c == 'l') do_list();
- X exit (0);
- X }
- X strcpy (buff, QUEUEPATH);
- X strcat (buff, ".");
- X strcat (buff, queuename);
- X strcat (buff, "rc");
- X fpq = fopen (buff, "r");
- X if (fpq == NULL)
- X {
- X printf ("Can't access initialisation file: %s\n", buff);
- X fclose (fpq);
- X exit (-1);
- X }
- X jobuid = getuid();
- X jobgid = getgid();
- X fgets (buff, 128, fpq);
- X permission = 0;
- X fixedcontext = 0;
- X while (*buff != 0)
- X {
- X sscanf (buff, "%s", rcmd);
- X if (strcmp (rcmd, "#QUSERS") == 0)
- X {
- X fixedcontext = 1;
- X if (permission > 0) break;
- X permission = 0;
- X /* check uid against list of permitted id's */
- X i = sscanf (buff,"%s%d%d%d%d%d%d%d%d%d%d", rcmd,
- X &qpuid[0],&qpuid[1],&qpuid[2],&qpuid[3],
- X &qpuid[4],&qpuid[5],&qpuid[6],&qpuid[7],
- X &qpuid[8],&qpuid[9]);
- X for (j=0; j < i; j++)
- X if (qpuid[j] == jobuid)
- X {
- X permission ++;
- X break;
- X }
- X }
- X if (strcmp (rcmd, "#QGROUPS") == 0)
- X {
- X fixedcontext = 1;
- X if (permission > 0) break;
- X permission = 0;
- X /* check gid against list of permitted id's */
- X i = sscanf (buff,"%s%d%d%d%d%d%d%d%d%d%d", rcmd,
- X &qpgid[0],&qpgid[1],&qpgid[2],&qpgid[3],
- X &qpgid[4],&qpgid[5],&qpgid[6],&qpgid[7],
- X &qpgid[8],&qpgid[9]);
- X for (j=0; j < i; j++)
- X if (qpgid[j] == jobgid)
- X {
- X permission ++;
- X break;
- X }
- X }
- X *buff = 0;
- X fgets (buff, 128, fpq);
- X }
- X fclose(fpq);
- X if ((permission == 0) && (jobuid != 0) && (fixedcontext == 1)) exit (-1);
- X if (c == 'l') do_list();
- X exit(0);
- X}
- END_OF_FILE
- if test 4128 -ne `wc -c <'src/qt.c'`; then
- echo shar: \"'src/qt.c'\" unpacked with wrong size!
- fi
- # end of 'src/qt.c'
- fi
- if test -f 'src/time.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/time.c'\"
- else
- echo shar: Extracting \"'src/time.c'\" \(2608 characters\)
- sed "s/^X//" >'src/time.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* time.c Profile timing functions */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X/*********************************************************************
- X*
- X* The purpose of this module is to provide some profiling and user
- X* accounting facilities to QBATCH. The time values as stored are in
- X* resolutions of 1/100 secs. The clock resolution on your system may
- X* (probably will) not be this accurate. For user and system times,
- X* the times function returns the total time in clock ticks (the highest
- X* resolution) into a struct tms. On SYSV systems, the return value is
- X* a useful timebase also (in clock ticks). Other (BSD?) systems simply
- X* return zero to imply success. In these cases, you will have to find
- X* some other way to find out the real time in 1/100 secs, or put up
- X* with using time(), and do without the fractions.
- X*
- X* Two functions are defined in this module:
- X*
- X* qb_start_timer(): Initialise variables so that the base values
- X* of the intervals is known.
- X*
- X* qb_get_timer(): calculate the intervals in 1/100 secs from the
- X* base values previously set.
- X*
- X* Three values (intervals) are to be maintained:
- X* (all 1/100 sec resolution)
- X*
- X* The 'real' time (i.e. clock time)
- X*
- X* CPU usage for user instructions for child processes.
- X*
- X* CPU usage for system execution for child processes.
- X*
- X* IMPORTANT These functions work together. Results are indeterminate
- X* if they are not called in order.
- X*
- X*********************************************************************/
- X#include <unistd.h>
- X#include <sys/types.h>
- X#include <sys/times.h>
- X#include "config.h"
- struct tms start_times, end_times;
- clock_t real_start, real_end;
- int clock_tick = 0;
- void qb_set_timer()
- X{
- X if (!clock_tick) clock_tick = QCLOCK_TICK;
- X real_start = times (&start_times);
- X}
- void qb_get_timer(real, user, system)
- unsigned long *real, *user, *system;
- X{
- X real_end = times(&end_times);
- X *real = ((real_end - real_start) *100) / clock_tick;
- X *user = ((end_times.tms_cutime - start_times.tms_cutime) *100) / clock_tick;
- X *system = ((end_times.tms_cstime - start_times.tms_cstime) *100) / clock_tick;
- X}
- END_OF_FILE
- if test 2608 -ne `wc -c <'src/time.c'`; then
- echo shar: \"'src/time.c'\" unpacked with wrong size!
- fi
- # end of 'src/time.c'
- fi
- echo shar: End of archive 2 \(of 6\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-